home *** CD-ROM | disk | FTP | other *** search
- /* FILE: testdrv.c
- **
- ** Copyright 1990 by Microsoft, All Rights Reserved.
- **
- ** of TESTDRV.EXE
- **
- ** Device Driver Test for MSCDEX compatible CD-ROM.
- ** Tests most aspects of direct driver requests detailed
- ** in Document 000080010-100-O00-1186 Microsoft Device
- ** Driver Specification.
- **
- ** NOTES: main, supporting procedures, global declarations
- **
- ** Created 7/15/90 - JYG
- ** Final (v1.0) 10/01/90 - JYG
- ** Created 12/06/91 -Siddhartha Roy
- **
- */
-
- #include"test.h"
-
- /*
- ** Global Variable Declarations
- */
-
- /*
- ** Many of the conventions here are non-standard
- **
- ** KEY: f preceding a label is a flag (typically signed char)
- ** c preceding a label is a counter (typically WORD)
- ** b preceding a label is a byte (typically BYTE)
- ** p preceding a label is a pointer (implied near without modifier)
- ** m preceding a label is an array
- ** t preceding an all upcase label is an index into an array
- ** of pointers to functions
- ** r preceding an all upcase label is an index into an array
- ** of request structures
- ** sz preceding a label is a zero ('\0') terminated string
- ** i preceding a label is a generic index
- ** l preceding a label is a long
- ** ch preceding a label is a signed char
- ** lp preceding a label is a long pointer
- */
-
- FLAG fInteract, fIgnoreCtrl, fWriteMedia, fRedbook, fRaw, fPrefetch,
- fAudCtrl, fAudio, fInterleave, fEject, fUPC, fRedSector,
- fHSGSector, fVerbose, fPrep, fSubInfo;
-
- BYTE bInterSize,bInterSkip; // Interleave Support
-
- FILE *pOutFile; // output file for hex dumps
- FILE *pInFile; // input profile
-
- WORD cwWarnings, cwErrors; // Error-Level Counters
- WORD cwSkipped; // User Skipped Tests
- WORD cwRequests; // Total number of requests
- WORD iFirstDrvLetter; // First Drive
- WORD cwNumDrives; // Number of Drives
- WORD bDriveNumber; // Current Drive Number
- WORD cwAudioChan; // Number of Audio Channels
- WORD wDriveNum; // Drive Number
-
- WORD cwRedSectors,cwHSGSectors; // Number of testing sectors
-
- DWORD mplHSGSector[10]; // HSG sectors to read
- DWORD mplRedSector[10]; // Redbook sectors to read
-
- char *szStdPath; // Standard Path or from TESTDRV env
-
- char szDriverName[256]; // Driver Name
-
- //
- // Local Functions
- //
-
- static void UsageMsg(void);
- /*
- ** testdrv( Dev_List * )
- ** - main testing routine.
- */
- void testdrv( drv )
- Dev_List *drv;
- {
- extern FLAG fIgnoreCtrl;
- extern WORD cwRequests,cwErrors,cwWarnings;
-
- printf( "\n\tCODE\tSTATUS\tMESSAGE\n" );
- printf( "\t=====\t======\t=======\n");
- printf( "\n[NON-DISC SPECIFIC TESTS]\n" );
-
- (*mTestTbl[tINIT])( drv );
- (*mTestTbl[tDEVSTAT])( drv );
- (*mTestTbl[tRADDR])( drv );
- (*mTestTbl[tRESET])( drv );
- (*mTestTbl[tLOCKDOOR])( drv );
- (*mTestTbl[tDRVBYTES])( drv );
-
- /*
- ** The following test has been disabled. For more thorough tests,
- ** re-activate. It tests 256 commands.
- */
-
- // (*mTestTbl[tRESERVEDCMD])( drv );
-
- (*mTestTbl[tSECTORSIZE])( drv );
- (*mTestTbl[tUPCCODE])( drv );
- (*mTestTbl[tVOLSIZE])( drv );
-
- if ( fInteract )
- (*mTestTbl[tEJECT])( drv );
-
- if ( fAudio )
- (*mTestTbl[tAUDIODISK])( drv );
-
- if ( fIgnoreCtrl )
- (*mTestTbl[tSECTORDUMP])( drv );
- else
- (*mTestTbl[tTESTCONTROL])( drv );
-
- printf( "\n\t%d - Errors\n\t%d - Warnings\n\t%d - Requests",
- cwErrors,cwWarnings,cwRequests );
-
- exit( cwErrors );
-
- }
-
- static void UsageMsg()
- {
- printf( "USAGE: TESTDRV [filename.pro] [/A] [/I] [/T]\n" );
- printf( "\t/# - (where # is a number from 0-7) The drive unit number\n" );
- printf( "\t/A - Attended Mode\n" );
- printf( "\t/I - Ignore Control Disks\n" );
- printf( "\t/T - Terse output (verbose is default)\n" );
- printf( "\t[FILENAME] - Alternate Profile\n" );
- printf( "\nThe location of sample archives is assumed to be the current directory, but" );
- printf( "\nmay be specified by setting the TESTDRV environment variable." );
- printf( "\n\nStatus Line Format:" );
- printf( "\n<CODE>\t<STATUS>\t<COMMAND>:<COMMENT>\n" );
- printf( "\nThe status field can be blank or:" );
- printf( "\n\t*ERROR* - High priority error, generated by the driver" );
- printf( "\n\t-ERROR- - Error, generated by this application" );
- printf( "\n\tWARNING - Unusual event, possibly hardware dependent" );
- printf( "\n\tTESTING - Announcement of a device request (verbose mode)\n" );
- printf( "------------------------------------------------------------------------------\n" );
- printf( "Note: In verbose mode, all requests made to the driver are noted on standard\n" );
- printf( "output. All requests will be followed by a translation of the returned\n" );
- printf( "status bits combination, i.e. ERROR BUSY and DONE.\n" );
- printf( "------------------------------------------------------------------------------\n" );
- exit(2);
- }
-
- /*
- ** main() does the Request line parsing, calls the setup and starts the
- ** test.
- */
-
- #define PROFILE_STRING "TESTDRV.pro"
-
- void main( argc , argv )
- int argc;
- char *argv[];
- {
- extern FLAG fInteract,fIgnoreCtrl,fVerbose,fPrep;
- extern WORD cwNumDrives;
- extern char * szStdPath;
- extern WORD wDriveNum;
-
- static char szDefProfile[] = PROFILE_STRING;
-
- Dev_List Dev_Tbl[26]; /** For a maximum of 26 drives **/
- FILE *pInFile;
- short n;
- char *pchProfile;
- char szFullPath[256];
-
- printf( "\n\tMicrosoft CD-ROM Device Driver Test, Version 1.0\n" );
- printf( "\tCopyright 1990 by Microsoft Corp., All Rights Reserved.\n\n" );
-
- pchProfile = szDefProfile;
- fInteract = FALSE;
- fIgnoreCtrl = FALSE;
- fVerbose = TRUE;
- fPrep = FALSE;
- wDriveNum = 0;
-
- // Parse the command line out
-
- for( n=1;n<argc;n++ ) {
- if ( argv[n][0] == '/' || argv[n][0] == '-' ) {
- switch ( toupper(argv[n][1]) ) {
- case 'A': // attended testing
- fInteract = TRUE;
- break;
- case 'I': // ignore control disks
- fIgnoreCtrl = TRUE;
- break;
- case 'T': // no hex dumps
- fVerbose = FALSE;
- break;
- case 'P': // prep mode
- fPrep = TRUE;
- break;
-
- case '0': case '1': case '2': case '3':
- case '4': case '5': case '6': case '7':
- wDriveNum = argv[n][1]-'0';
- break;
- case '?': default:
- UsageMsg();
- break;
- }
- } else if ( pchProfile == szDefProfile ) //Check user defined profile
- pchProfile = argv[n]; // Yank it in
- else UsageMsg();
-
- }
-
- // Check environment for profile pathname
-
- if ((szStdPath = getenv("TESTDRV"))!=NULL)
- sprintf(szFullPath,"%s\\%s",szStdPath,pchProfile);
- else sprintf(szFullPath,"%s",pchProfile);
-
- #ifdef DEBUG
- printf("PROFILE: %s\n",szFullPath);
- #endif
-
- if ( (pInFile = fopen( szFullPath,"r" ))==NULL )
- {
- printf( "Cannot open profile '%s'\n",szFullPath );
- fatalError( "Exiting." );
- }
-
- //
- // Setup from file
- //
-
- setup( pInFile );
-
- //
- // Locate drivers and store the information in Dev_Tbl
- //
-
- find_drivers( Dev_Tbl );
-
- printf( "\n\tTESTING DRIVE %d\n",wDriveNum );
- if ( wDriveNum >= cwNumDrives )
- fatalError( "Drive number out of range, Exiting." );
-
- //
- // Is the driver valid?
- //
-
- printf("\n\tVerifying Drive Name ...");
-
- if (_fstricmp((Dev_Tbl[wDriveNum].dev_addr)->sdevname,szDriverName)){
- printf( "\n\tDrive Signature '%s' in profile does not match drive table.\n",
- szDriverName );
- fatalError("Exiting");
- }
- printf(" Okay \n");
-
-
-
-
- #ifdef PREPARE
-
- if ( fPrep )
- prepData( Dev_Tbl+wDriveNum );
- else
-
- #endif
-
- testdrv( Dev_Tbl+wDriveNum );
-
- }
-